####################################################################################
###Appendix Figure C4: Specifications with Alternative Outcomes#####################
####################################################################################
fig_A8a1 <- lm(supp_auth2 ~ unauthorised + age + gender +education, data = dat)
fig_A8a2 <- lm(supp_auth2 ~ violent + age + gender +education, data = dat)
fig_A8a3 <- lm(supp_auth2 ~ arrest + age + gender +education, data = dat)

fig_A8b1 <- lm(supp_arrest2 ~ unauthorised + age + gender +education, data = dat)
fig_A8b2 <- lm(supp_arrest2 ~ violent + age + gender +education, data = dat)
fig_A8b3 <- lm(supp_arrest2 ~ arrest + age + gender +education, data = dat)

fig_A8c1 <- lm(diffsupp2 ~ unauthorised + age + gender +education, data = dat)
fig_A8c2 <- lm(diffsupp2 ~ violent + age + gender +education, data = dat)
fig_A8c3 <- lm(diffsupp2 ~ arrest + age + gender +education, data = dat)

dat_unauth <-subset(dat, unauthorised==1)
dat_auth <-subset(dat, unauthorised==0)
dat_auth$arr<-dat_auth$arrest

fig_A8d1 <- lm(supp_arrest2 ~ arrest + age + gender +education, data = dat_unauth)
fig_A8d2 <- lm(supp_arrest2 ~ arr + age + gender +education, data = dat_auth)

testplot1<-plot_summs(fig_A8a1, fig_A8a2, fig_A8a3,
                      coefs = c("Protest Unauthorized" = "unauthorised", "Demonstrators Violent" = "violent",
                                "Demonstrators Arrested" = "arrest"), color.class = "Greys",
                      scale = TRUE, robust = FALSE)

testplot2<-plot_summs(fig_A8b1, fig_A8b2, fig_A8b3,
                      coefs = c("Protest Unauthorized" = "unauthorised", "Demonstrators Violent" = "violent",
                                "Demonstrators Arrested" = "arrest"), color.class = "Greys",
                      scale = TRUE, robust = FALSE)

testplot20<-plot_summs(fig_A8d1, fig_A8d2,
                       coefs = c("Demonstrators Arrested, Authorized " = "arrest",
                                 "Demonstrators Arrested, Unauthorized" = "arr"), color.class = "Greys",
                       scale = TRUE, robust = FALSE)

testplot3<-plot_summs(fig_A8c1, fig_A8c2, fig_A8c3,
                      coefs = c("Protest Unauthorized" = "unauthorised", "Demonstrators Violent" = "violent",
                                "Demonstrators Arrested" = "arrest"), color.class = "Greys",
                      scale = TRUE, robust = FALSE)


apatheme= theme_apa(
  legend.pos = "",
  legend.use.title = FALSE,
  legend.font.size = 12,
  x.font.size = 12,
  y.font.size = 19,
  facet.title.size = 10,
  remove.y.gridlines = TRUE,
  remove.x.gridlines = TRUE
)

final1<-testplot1  + apatheme + theme(axis.text = element_text(size =16)) + theme(axis.title.x = element_text(size=14)) + labs(x = "Authorities' Assessments", y = "")  
final2<-testplot2 + apatheme + theme(axis.text = element_text(size =16)) + theme(axis.title.x = element_text(size=14)) + labs(x = "Police Assessments", y = "")  
final20<-testplot20 + apatheme + theme(axis.text = element_text(size =12)) + theme(axis.title.x = element_text(size=14)) + labs(x = "Police Assessments", y = "")  
final3<-testplot3  + apatheme + theme(axis.text = element_text(size =16)) + theme(axis.title.x = element_text(size=14)) + labs(x = "Authorities-Demonstrators", y = "")  


ggsave(height=6,
       width=16,
       "Figures/alternative_outcomes.png",
       arrangeGrob(final1, final3, final2, final20, ncol=2)
)
